﻿using System;

class AllDistinctNumbers
{
    static void Main()
    {
        Console.Write("Number N: ");
        int numberN = int.Parse(Console.ReadLine());

        Console.Write("Number K: ");
        int numberK = int.Parse(Console.ReadLine());

        //int numberN = 5;
        //int numberK = 2;

        int[] pickedNumbers = new int[numberK];
        GenerateAllDistinctNumbers(pickedNumbers, 0, 1, numberN);
    }

    static void GenerateAllDistinctNumbers(int[] pickedNumbers, int index, int start, int end)
    {
        if (index != pickedNumbers.Length)
        {
            for (int i = start; i <= end; i++)
            {
                pickedNumbers[index] = i;
                GenerateAllDistinctNumbers(pickedNumbers, index + 1, i + 1, end);
            }
        }
        else
        {
            Print(pickedNumbers);
        }
    }

    static void Print(int[] array)
    {
        Console.WriteLine();
        for (int i = 0; i < array.Length; i++)
        {
            Console.Write(" " + array[i]);
        }
        Console.WriteLine();
    }
}